import React from 'react'
import { Switch, Redirect } from 'react-router'
import { PrivateRoute } from 'components/route'
import List from './list'
import NewInvite from './new'
import EditInvite from './edit'

export default ({ location, match, org }) => (
  <Switch location={location}>
    <PrivateRoute
      path={`${match.url}/list`}
      render={props => <List {...props} org={org} />}
      exact
    />
    <PrivateRoute
      path={`${match.url}/new`}
      render={props => <NewInvite {...props} org={org} />}
      exact
    />
    <PrivateRoute path={`${match.url}/edit/:user`} component={EditInvite} exact />
    <Redirect from={`${match.url}`} to={`${match.url}/list`} />
  </Switch>
)
